{echo:JS::import('dialog?skin=brief');}
{echo:JS::import('dialogtools');}
{echo:JS::import('form');}
<form name="zform" action="" method="post">
    <div class="tools_bar clearfix">
        <!-- <a class="icon-checkbox-checked icon-checkbox-unchecked" href="javascript:;" onclick="tools_select('id[]',this)" title="全选" data="true"> 全选 </a> -->
        <!-- <a  class="icon-remove-2" href="javascript:;" onclick="tools_submit({action:'{url:/customer/customer_del}',msg:'删除后无法恢复，你真的删除吗？'})" title="删除"> 删除</a> -->
        <!--
        <a href='{url:/customer/customer_edit}' class="icon-plus" > 添加</a>
        -->
        <a class="icon-delicious" href="{url:/customer/customer_list}"> 全部用户</a>
        <span class="fr"><a href='javascript:;' id="condition" class="icon-search" style=""> 筛选条件</a><input
                id="condition_input" type="hidden" name="condition" value="{$condition}"></span>
    </div>
    <table class="default">
        <tr>
            <th style="width:50px"></th>
            <th style="width:70px">操作</th>
            <th>账号</th>
            <th>姓名</th>
            <!--<th>编码</th>-->
            <th>推荐人</th>
            <th>直推人数</th>
            <!--<th>分红奖</th>-->
            <!--<th>扩展将</th>-->
            <!--<th>助力奖</th>-->
            <th>注册分</th>
            <th>奖金分</th>
            <th>现金分</th>
            <th>购物积分</th>
            <th>重消积分</th>
            <th>资产</th>
            <th>剩余分红积分</th>
            <th style="width:120px">注册时间</th>
            <th>状态</th>
            <th>分红级别</th>
            <th>投资级别</th>
            <th width="150px;">代理地域</th>

        </tr>
        {query:name=customer as c,user as u where=c.user_id eq u.id and u.status eq 1 and $where id=$obj page=1 pagesize=13 order=u.id
        desc }
        <tr>

            <td><a href="{url:/simple/pt_login_act/user_id/$item[id]}" class="button" target="_blank">前台</a></td>

            <td style="width:70px" class="btn_min">

                <div class="operat hidden"><a class="icon-cog action" href="javascript:;"> 处理</a>
                    <div class="menu_select">
                        <ul>
                            <li><a class="icon-coin" href="javascript:balance_op({$item['user_id']},2);"> 充值</a></li>
                            <li><a class="icon-credit" href="javascript:balance_op({$item['user_id']},4);"> 扣款</a></li>

                            {if:$item['is_seller']==0}
                            <li><a class="icon-pencil"
                                   href="javascript:" onclick ="view({$item['id']})">设为商家</a>
                            </li>
                            {/if}

                            <li><a class="icon-pencil"
                                   href="javascript:" onclick ="view_vip({$item['id']})">投资升降级</a>
                            </li>
                            <li><a class="icon-pencil"
                                   href="javascript:" onclick ="view_vip_fh({$item['id']})">分红升降级</a>
                            </li>
                            <li><a class="icon-pencil red"
                                   href="javascript:confirm_action('{url:/customer/ok_withdraw/id/$item[id]}','确认执行此操作吗？')">
                                {echo:$item['lock']==0?"禁止提现":"允许提现";}</a></li>
                            <!--<li><a class="icon-pencil"-->
                                   <!--href="javascript:confirm_action('{url:/customer/set_u_lx/id/$item[id]/lx/1}','确认执行此操作吗？')">-->
                                <!--开通服务中心</a></li>-->
                            <!--{if:$item['u_lx']==1}-->
                            <!--<li><a class="icon-pencil"-->
                                   <!--href="javascript:confirm_action('{url:/customer/unset_u_lx/id/$item[id]}','确认执行此操作吗？')">-->
                                <!--取消服务中心</a></li>-->
                            <!--{/if}-->
                            <!--<li><a class="icon-pencil"-->
                                   <!--href="javascript:confirm_action('{url:/customer/set_u_lx/id/$item[id]/lx/2}','确认执行此操作吗？')">-->
                                <!--开通分公司</a></li>-->
                            <!--{if:$item['u_lx']==2}-->
                            <!--<li><a class="icon-pencil"-->
                                   <!--href="javascript:confirm_action('{url:/customer/unset_u_lx/id/$item[id]}','确认执行此操作吗？')">-->
                                <!--取消分公司</a></li>-->
                            <!--{/if}-->
                            <li><a class="icon-pencil red"
                                   href="javascript:confirm_action('{url:/customer/customer_nojj/id/$item[id]}','确认执行此操作吗？')">
                                {echo:$item['nojj']==0?"冻结":"解冻";}</a></li>
                            {if:$item['status']>0}
                            <li><a class="icon-pencil red"
                                   href="javascript:confirm_action('{url:/customer/customer_clock/id/$item[id]}','确认执行此操作吗？')">
                                {echo:$item['status']==1?"锁定":"解锁";}</a></li>
                            {/if}
                            <!--{if:$item['status']>0}-->
                           <!---->
                            <!--<li><a class="icon-pencil red" href="javascript:confirm_action('{url:/customer/tjr_ok/id/$item[id]}','确认此操作吗？')"> {echo:$item['tjr_index']==0?"注册选择":"取消注册选择";}</a></li>-->
                           <!---->
                            <!--{/if}-->
                            <li><a class="icon-pencil" href="{url:/customer/customer_edit/id/$item[id]}"> 编辑</a></li>
                            <!-- <li><a class="icon-remove-2" href="javascript:confirm_action('{url:/customer/customer_del/id/$item[id]}')"> 删除</a></li> -->
                        </ul>
                    </div>
                </div>
            </td>
            <td>{$item['name']}
                {if:$item['is_seller']==1}
                <b style="color:red;">商</b>
                {/if}
            </td>
            <td>{$item['real_name']}
            </td>
            <!--<td>{$item['number']}</td>-->
            <td>{echo:Common::getC($item['tjr_id'])['real_name']}</td>
            <td>{$item['u_tjrs']}</td>
            <!--<td>-->
            <!--冻结:{$item['dj_xfjf']}<br>-->
            <!--可用:{$item['ok_xfjf']}<br>-->
            <!--已释放:{$item['sf_xfjf']}-->
            <!--</td>-->
            <td>{$item['zcf']}</td>
            <!--<td>-->
            <!--{$item['fhj']}-->
            <!--</td>-->
            <!--<td>-->
            <!--{$item['kzj']}-->
            <!--</td>-->
            <!--<td>-->
            <!--{$item['zlj']}-->
            <!--</td>-->
            <td>{$item['jjf']}&nbsp;&nbsp;<span class='red'>{echo:$item['lock']==1?"禁":"";}</span></td>
            <td>{$item['xjf']}</td>
            <td>{$item['gwjf']}</td>
            <td>{$item['cxjf']}</td>
            <td>{$item['zc']}</td>
            <td>{$item['last_fhjf']}</td>
            <td>{$item['reg_time']}</td>
            <td>
                {if:$item['is_hg']==1}
                合格&nbsp;
                {/if}
                {echo:$item['status']==0?"未激活":($item['status']==1?"正常":"锁定");}&nbsp;&nbsp;<span class='red'>{echo:$item['nojj']==1?"冻结":"";}</span>
            </td>
            <!-- <td style="width:80px">{$grade_name[$item['group_id']]|'默认会员'}</td> -->
            <!--<td>-->
            <!--{echo:Common::getShenfenname($item['u_lx'])}-->
            <!--&lt;!&ndash;-->
            <!--{echo:Common::getShenfenName($item['u_lx'])}&nbsp;&nbsp;<span class='red'>{echo:Common::getAgentName($item['dl_lx'])}</span>&nbsp;&nbsp;{echo:$item['lgd_ok']>0?Common::getShenfenName($item['lgd_ok']):"";}&nbsp;&nbsp;{echo:$item['gd_ok']>0?Common::getShenfenName($item['gd_ok']):"";}-->
            <!--&ndash;&gt;-->
            <!--</td>-->
            <td>
                {if:$item['vip_id'] == 0}
                无
                {elseif:$item['vip_id'] == 1}
                一级代理
                {elseif:$item['vip_id'] == 2}
                二级代理
                {elseif:$item['vip_id'] == 3}
                县代理
                {elseif:$item['vip_id'] == 4}
                市代理
                {/if}
            </td>
            <td>
                {if:$item['group_id'] == 0}
                无
                {elseif:$item['group_id'] == 1}
                一级代理
                {elseif:$item['group_id'] == 2}
                二级代理
                {elseif:$item['group_id'] == 3}
                县代理
                {elseif:$item['group_id'] == 4}
                市代理
                {/if}
            </td>
            <td>{echo:Common::area_name($item['dl_area'])}</td>
        </tr>
        {/query}
    </table>
</form>
<div class="page_nav">
    {echo:$obj->pageBar()}
</div>


<div id="balance_box" style="display: none;width:650px;padding: 5px;" class="box">
    <h2 class="page_title tc" style="border:none" id="balance-title">充值</h2>
    <div class="form2">
        <form id="export_form" action="{url:/customer/balance_act}" method="post" callback="create_voucher">
            <input type="hidden" id="user_id" name="user_id" value="">
            <input type="hidden" id="type" name="type" value="">
            <dl class="lineD">
                <dt>钱包类型：</dt>
                <dd>
                    <input type="radio" name="account_type" value="1"/>注册分&nbsp;
                    <input type="radio" name="account_type" value="2"/>奖金分&nbsp;
                    <input type="radio" name="account_type" value="3"/>现金分&nbsp;
                    <input type="radio" name="account_type" value="4"/>购物积分&nbsp;
                    <input type="radio" name="account_type" value="5"/>重消积分&nbsp;
                    <input type="radio" name="account_type" value="6"/>资产&nbsp;
                    <input type="radio" name="account_type" value="7"/>剩余分红&nbsp;
                </dd>
                <dt>&nbsp;&nbsp;</dt>
                <!--<dd>-->
                <!--<input type="radio" name="account_type" value="7"/>消费券&nbsp;-->
                <!--<input type="radio" name="account_type" value="5"/>推广额度(总额)&nbsp;-->
                <!--<input type="radio" name="account_type" value="8"/>推广额度(剩余)&nbsp;-->
                <!--<input type="radio" name="account_type" value="9"/>推广额度(已用)-->


                <!--</dd>-->
            </dl>

            <dl class="lineD">
                <dt style="margin-left:-140px;">金额：</dt>
                <dd><input id="amount" pattern="float" min="0.01" name="amount" alt="最少0.01"> <label
                        id="lb_msg"></label></dd>
            </dl>
            <div class="tc mt10">
                <button class="button" id="balance-btn">充值</button>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    function view(id){
        art.dialog.open("{url:/customer/dp_view/id/}"+id,{id:'edit_dialog',title:'店铺信息',resize:false,width:500,height:300});
    }
    function view_vip(id){
        art.dialog.open("{url:/customer/up_down_list/id/}"+id,{id:'edit_dialog',title:'投资升降级',resize:false,width:500,height:300});
    }

    function view_vip_fh(id){
        art.dialog.open("{url:/customer/up_down_list_fh/id/}"+id,{id:'edit_dialog',title:'分红升降级',resize:false,width:500,height:200});
    }

    function close(){
        art.dialog({id:'edit_dialog'}).close();
        art.dialog.tips("<p class='success'>设置成功！</p>");
        window.location.reload();
    }

    //将输入的数字金额转换成对应的中文大写金额
    //idNumber输入的数字金额，idCHN输出的中文大写金额
    function TransformNumberIntoCHN(number) {
        if (!/^(0|[1-9]\d*)(\.\d{1,2})?$/.test(number)) {

            return false;
        }
        var unit = "仟佰拾亿仟佰拾万仟佰拾元角分", str = "";
        number += "00";
        var point = number.indexOf('.');
        if (point >= 0) {
            number = number.substring(0, point) + number.substr(point + 1, 2);
        }
        unit = unit.substr(unit.length - number.length);
        for (var i = 0; i < number.length; i++) {
            str += '零壹贰叁肆伍陆柒捌玖'.charAt(number.charAt(i)) + unit.charAt(i);
        }
        //document.getElementById(idCHN).value = str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|壹(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
        return str.replace(/零(仟|佰|拾|角)/g, "零").replace(/(零)+/g, "零").replace(/零(万|亿|元)/g, "$1").replace(/(亿)万|(拾)/g, "$1$2").replace(/^元零?|零分/g, "").replace(/元$/g, "元整");
    }

    $(function () {
        $("#amount").blur(function () {
            var amount = $("#amount").val();
            if (isNaN(amount) || amount == '') {
                $("#lb_msg").text('');
                return;
            }
            var dxje = TransformNumberIntoCHN(amount);
            $("#lb_msg").text(dxje);
        });
    });



    function balance_op(user_id, type) {
        $("#user_id").val(user_id);
        $("#type").val(type);
        var title = "充值";
        if (type == 4) title = "扣款";
        $("#balance-title").text(title);
        $("#balance-btn").text(title);
        $("#amount").val('');
        art.dialog({
            id: 'balance_op',
            lock: true,
            opacity: 0.1,
            title: title,
            width: 600,
            height: 200,
            padding: "15px",
            content: document.getElementById("balance_box")
        });
    }
    function create_voucher(e) {
        if (e == null) {
            $("#balance-btn").attr("disabled", true);
            var fields = $("#export_form").serializeArray();
            $.get("{url:/customer/balance_op}", fields, function (data) {
                if (data['status'] == 'success') {
                    art.dialog({id: 'balance_op'}).close();
                    art.dialog.tips("<p class='" + data['status'] + "'>" + data['msg'] + "</p>", 2);
                    setTimeout("tools_reload()", 2000);
                } else {
                    art.dialog.tips("<p class='" + data['status'] + "'>" + data['msg'] + "</p>");
                }
                $("#balance-btn").attr("disabled", false);
            }, 'json');
        }
        return false;
    }
</script>

<script type="text/javascript">
    var form = new Form();
    $("#condition").on("click", function () {
        //$("body").Condition({input:"#condition_input",okVal:'高级搜索',callback:function(data){tools_submit({action:'{url:/customer/customer_list}',method:'get'});},data:{'name':{name:'账号'},real_name:{name:'姓名'},status:{name:'是否锁定',values:{1:'正常',2:'锁定'}},nojj:{name:'是否冻结',values:{0:'正常',1:'冻结'}},u_lx:{name:'身份',values:{0:'普通',1:'创客',2:'商家'}},mobile:{name:'手机号码'},reg_time:{name:'注册时间'}
        $("body").Condition({
            input: "#condition_input", okVal: '高级搜索', callback: function (data) {
                tools_submit({action: '{url:/customer/customer_list}', method: 'get'});
            }, data: {
                'name': {name: '账号'},
                real_name: {name: '姓名'},
                status: {name: '是否锁定', values: {1: '正常', 2: '锁定'}},
                nojj: {name: '是否冻结', values: {0: '正常', 1: '冻结'}},
//                u_lx: {name: '身份', values: {0: '普通', 1: '服务中心', 2: '分公司'}},
                zcf: {name: '注册分'},
                jjf: {name: '奖金分'},
                xjf: {name: '现金分'},
                gwjf: {name: '购物积分'},
                cxjf: {name: '重消积分'},
                zc: {name: '资产'},
                last_fhjf: {name: '剩余分红积分'},
                reg_time: {name: '注册时间'},
                group_id: {name:'投资级别', values: {1: '一级代理', 2: '二级代理', 3: '县代理',4:'市代理'}}
            }
        });
    });
</script>
